﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.ViewModel;
using Telerik.Windows.Controls;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace HSE.Common
{
    public class TelerikGridViewModel:NotificationObject
    {




        public ICommand EditCommand { get; set; }

        

        public TelerikGridViewModel()
        {
            this.Mode = GridMode.View;
        }


        public List<ColumnInfo> Columns
        {
            get;
            set;
        }


        private Telerik.Windows.Controls.SelectionMode _selectionMode;
        public Telerik.Windows.Controls.SelectionMode SelectionMode
        {
            get { return this._selectionMode; }
            set
            {
            	this._selectionMode = value;
                this.RaisePropertyChanged("SelectionMode");
            }
        }

        private ObservableCollection<object> _selectItems;
        public ObservableCollection<object> SelectItems
        {
            get
            {
                return this._selectItems;
            }

            set
            {
            	
                {
                    if (this._selectItems != value) {
                        this._selectItems = value;
                        this.RaisePropertyChanged("SelectItems");
                    }
                }
            }
        }

        private GridMode _mode;
        public GridMode Mode
        {
            get { return this._mode; }
            set
            {
            	this._mode = value;

                if (_mode == GridMode.View)
                {
                    this.SelectionMode = Telerik.Windows.Controls.SelectionMode.Single;
                    this.EditVisibility = Visibility.Collapsed;
                }
                else
                {
                    this.SelectionMode = Telerik.Windows.Controls.SelectionMode.Extended;
                    this.EditVisibility = Visibility.Visible;
                }
            }
        }

        private Visibility _editVisibility;
        public Visibility EditVisibility
        {
            get { return this._editVisibility; }
            set
            {
                this._editVisibility = value;
                this.RaisePropertyChanged("EditVisibility");
            }
        }

        private List<int> _pages = new List<int>();
        public List<int> Pages
        {
            get { return this._pages; }
            set {
                this._pages = value;
                this.RaisePropertyChanged("Pages");
            }
        }

        private int _currentpage = 1;
        public int CurrentPage
        {
            get { return this._currentpage; }
            set {
                this._currentpage = value;
                this.RaisePropertyChanged("CurrentPage");
            }
        }
    }

    public class ColumnInfo
    {
        public GridViewColumn Column { get; set; }

        public ButtonInfo ButtonInfo { get; set; }
    }

    public enum GridMode
    {
        View,
        Edit
    }
}
